#include<bits/stdc++.h>
using namespace std;
int n,t,u,k,v,a[100005],b[100005],s[100005],h[100005];
int ssolve1()
{
	int s1=0,s2=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==1) s1++;
		else if(a[i]==2) s2++;
	}
	if(s1==0||s2==0)
	{
		return max(s1,s2);
	} 
	else
	{
		if(s1>s2)
		{
			return n-s2;
		}
		else
		{
			return n-s1;
		}
	}
}
void ssolve2()
{
	k=1;
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		h[a[i]]++;
	}
	for(int i=1;i<=t;i++)
	{
		if(h[i]!=0)
		{
			b[k]=h[i];
			k++;
		}
	}
	k--;
	for(int i=1;i<=k;i++)
	{
		s[i]=b[i-1]+s[i-1];
	}
	for(int i=2;i<=k;i++)
	{
		if(b[i]<=s[i]-v)
		{
			u+=b[i];
			v+=b[i];
		}
		else
		{
			v+=s[i];
			u+=s[i];
		}
	}
	cout<<n-u;
}
int main()
{
	freopen("duel.in","r",stdin);
	freopen("duel.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		t=max(t,a[i]);
	}
	if(t<=2)
	{
		cout<<ssolve1();
	} 
	else 
	{
		ssolve2();
	}
	return 0;
}
